1. Field of the Invention
The present invention relates to a computer system and a method of detection of erroneous memory usage. More particularly, the present invention relates to methods of detection of erroneous memory usage in order to provide automatic detection of typical memory errors, such as a buffer overflow, including a buffer overflow inside a structure, a case when two allocated objects are rerecorded on top of one another, and unauthorized access, in computer programs.
2. Description of the Related Art
Recently, as computer systems have become increasingly complex, and provide wider variety functions using more processing, memory, and computer resources, program debugging has become more costly. In order to reduce efforts of software or computer program developers in program debugging, several approaches and methods have been developed. These methods can be divided on two main categories: static analysis methods and dynamic analysis methods. The methods of the respective categories may be used for detection of a wide set of problems. However, the methods of the respective categories have drawbacks which make the methods disadvantageous for detecting incorrect memory usage, which is a widespread problem that is difficult to detect.
The dynamic analysis methods are based on the information arriving or being processed during execution of a program. The dynamic analysis methods make it possible to detect incorrect memory calls which are out of an allocated memory range. Nevertheless, these methods are disadvantageous in a case having an error wherein two allocated objects are recorded one over one another, or there is an overflow of the buffer inside an allocated structure or part of a memory.
The static analysis methods are based on research or analysis of an initial code. However, the static analysis methods may not detect all problems associated with memory because of difficulty of achieving an accurate or useful analysis of the data flow for large computer systems. In other words, due to the increasing size of computer programs, the amount of time and resources used for static analysis also increases, thereby making the static analysis methods disadvantageous.
A method of detection of an incorrect allocation of memory having zero length in real time is known, as disclosed in U.S. Patent Application No. 2007/0136547, the entire disclosure of which is hereby incorporated by reference, and which describes a method of debugging of a standard program which incorrectly performs allocation of memory of zero length. However, the drawback of the noted method is that it may only detect allocation of memory of zero length, and thus the more complex memory errors, of memory access, such as overflow of the buffer and unauthorized memory access, may not be detected by the noted method.
A method of detection of overflow errors of memory during program execution is disclosed in U.S. Patent Application No. 2008/0052468, the entire disclosure of which is hereby incorporated by reference. Detection of such errors may occur due to attempted use of protected memory, which is not accessible because of the circumstances associated with the overflow of memory, such as access to non-allocated memory, and access to a stack of memory which is out of a stack area, or other similar circumstances. However, the noted method does not detect an incorrect memory call to memory which is allocated, for example, in a case when the object is rerecorded in memory during call to another object.
Another method of detecting incorrect usage of memory that is dynamically allocated is described in U.S. Patent Application No. 2005/0144410, the entire disclosure of which is hereby incorporated by reference, and which is based on data or a program stored in a tail-end of an allocated memory area, which has a specified value, and determining of the specified value during execution of the program or after the termination of the execution of the program. However, the noted method has a narrow field of application. More particularly, the noted method detects erroneous usage of the memory, which is allocated dynamically, and thus, segments of a memory stack and data cannot be checked by the noted method. Additionally, the noted method may detect memory errors in a predefined area of the memory, but may not detect memory errors in memory outside of the predefined area, such as when an object is rerecorded during a call to another object.